﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Kokomo.PeInspector.ObjectGraphs
{
	abstract class MemberTemplate
	{
		public abstract bool Inspect(object value);
	}
	abstract class MemberTemplate<TMember> : MemberTemplate
	{
		public NodeTemplate<TMember> Template { get; private set; }

		public MemberTemplate(
			NodeTemplate<TMember> template
			)
		{
			if (template == null) throw new ArgumentNullException("template");

			this.Template = template;
		}

		public override bool Inspect(object value)
		{
			object nodeValue = this.GetValue(value);

			return this.Template.Inspect(nodeValue);
		}

		protected abstract object GetValue(object target);
		protected abstract void SetValue(object target, object value);
	}
}
